package QuizPackage;

import static org.junit.Assert.*;

import java.sql.*;
import java.util.*;

import org.junit.Test;


public class PictureResponseTest {
	@Test
	public void smokeTest() {
		String[] r1 = {"Hoover Tower"};
		PictureResponse q1 = new PictureResponse(1, "hoovertower.jpg", r1);
		
		//System.out.println(q1.getHTML());
		
		String[] params = {"Hoover Tower"};
		assertEquals(1, q1.checkAnswer(params));
		assertEquals(q1.correctAnswer(), "Hoover Tower");
		 
	}
	
	@Test
	public void dbTest() {
		QuizDBC db = new QuizDBC();
		ResultSet questions = db.getQuestions(PictureResponse.tableName, 2);
		ArrayList<PictureResponse> questionList = new ArrayList<PictureResponse>();
		
		try {
			while (questions.next()) {
				int questionID = 1;
				String imageURL = questions.getString("imageURL");
				String[] response = {questions.getString("response")};
				
				
				PictureResponse q1 = new PictureResponse(questionID, imageURL, response);
				
				String[] params = {"Hoover Tower"};
				assertEquals(1, q1.checkAnswer(params));
				assertEquals(q1.correctAnswer(), "Hoover Tower");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}


